package com.adnaan.restaurant.mapper;

import com.adnaan.restaurant.entity.ResAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ResAddressMapper {

    @Insert("insert into res_address(street, detail, recipient, re_phone, user_id) values(#{street},#{detail},#{recipient},#{rePhone},#{userId})")
    int insertAddress(ResAddress resAddress);

    @Delete("delete from res_address where id = #{delId}")
    int deleteAddress(@Param("delId") Long id);

    @Update("update res_address set street = #{street},detail = #{detail},recipient = #{recipient},re_phone = #{rePhone} where id=#{id}")
    int updateAddress(ResAddress resAddress);

    @Select("select id, street, detail, recipient, re_phone, user_id from res_address where user_id = #{userId}")
    List<ResAddress> selectAddressListByuserId(Long userId);
}
